<template>
  <div class="app_containers big">
    <moitorHeader></moitorHeader>
    <div class="bgc">
      <div class="bgc_a">
        <div class="switchs"></div>
        <moitorSelect value="/newBraceletmonitoring"></moitorSelect>
      </div>
      <div class="bgc_b">
        <rwSelect
          v-model:value="queryParams.wardId"
          type="ward"
          className="down_Box"
          :xhrParams="{ data: 'data' }"
          @input="changeWard"
          @loadList="loadList"
        ></rwSelect>
        <!-- <a-select
          v-model:value="selectArea.types"
          @change="allRegions"
          dropdownClassName="down_Box"
        >
          <a-select-option value>全部区域</a-select-option> -->
        <!-- <a-select-option v-for="item in selectArea" :key="item.value" :value="item.value">{{
            item.label
          }}</a-select-option> -->
        <!-- </a-select> -->
      </div>
      <!-- <div class="bgc_b">
        <a-select
          v-model:value="selectArea.types"
          @change="allRegions"
          dropdownClassName="down_Box"
        >
          <a-select-option value>默认排序</a-select-option>
        
        </a-select>
      </div> -->
    </div>
    <div class="m_main">
      <div class="box">
        <div class="contentSection">
          <div
            class="box_a"
            :class="[hasSosAndLower(item).length > 0 ? '' : 'box_a_bg']"
            v-for="(item, id) of deviceList"
            :key="id"
          >
            <div class="box_text_a">
              <div class="box_text_b">{{ item.bedCode || "" }}床</div>
              <div class="box_text_d">
                {{ com.handleName(item.memberName || "", "name") }}
              </div>
              <div class="box_text_d">{{ item.memberSexStr || "" }}</div>
              <div class="box_text_d" v-show="item.memberAge">
                {{ item.memberAge || "" }}岁
              </div>
              <div class="box_text_d">{{ item.wardName || "" }}</div>
            </div>
            <div class="box_text_c" v-show="item.isCheckIn && item.deviceCode">
              <div
                class="box_text_g"
                :class="[isAlarm(item, monitorWarStrings.HEART) ? 'warning' : '']"
              >
                <div class="box_text_l code">心率</div>
                <div class="iconfont icon-xinlv code"></div>
                <div class="box_text_z code">{{ item.braceletHeartRate }}Bpm</div>
              </div>
              <div
                class="box_text_g"
                :class="[isAlarm(item, monitorWarStrings.BLOOD) ? 'warning' : '']"
              >
                <div class="box_text_l code">血压</div>
                <div
                  class="iconfont icon-icon_nurse_station_pressure_activate code"
                ></div>
                <div class="box_text_Y code">{{ item.lowBloodPressure }}mmHg</div>
                <div class="box_text_k code">{{ item.highBloodPressure }}mmHg</div>
              </div>
              <div
                class="box_text_g"
                :class="[isAlarm(item, monitorWarStrings.OXYGEN) ? 'warning' : '']"
              >
                <div class="box_text_l code">血氧</div>
                <div class="iconfont icon-spo2h_o code"></div>
                <div class="box_text_z code">{{ item.bloodOxygen }}%</div>
              </div>
              <div
                class="box_text_g"
                :class="[isAlarm(item, monitorWarStrings.TEMPERATURE) ? 'warning' : '']"
              >
                <div class="box_text_l code">体温</div>
                <div class="iconfont icon-thermometer code"></div>
                <!-- <Icon icon="ant-design:arrow-upOutlined" class="shang"></Icon> -->
                <div class="box_text_z code">{{ item.bloodOxygen }}°C</div>
              </div>
            </div>
            <p class="no_device" v-show="item.isCheckIn && !item.deviceCode">
              未&nbsp;&nbsp;绑&nbsp;&nbsp;定&nbsp;&nbsp;设&nbsp;&nbsp;备
            </p>
            <p class="no_device" v-show="!item.isCheckIn">空&nbsp;&nbsp;&nbsp;&nbsp;床</p>
            <div class="warn" v-show="hasSosAndLower(item).length > 0">
              <a-carousel autoplay :autoplaySpeed="1000" effect="fade" :dots="false">
                <div
                  class="warning"
                  :class="info.warnType"
                  v-for="info in hasSosAndLower(item)"
                >
                  <p class="time text">
                    {{ new Date(info.warnTime).toLocaleTimeString() }}
                  </p>
                  <p class="text warning_des">{{ info.warnTypeStr }}</p>
                </div>
              </a-carousel>
            </div>
          </div>
        </div>
        <moitorSlider :list="warning"></moitorSlider>
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { monitorWarStrings } from "/@/enums/alarmTypeEnum";
import moitorSelect from "/@/components/monitor/monitorSelect.vue";
import { ref, onMounted, onUnmounted } from "vue";
import "../../../assets/iconfont/iconfont.css";
import { router } from "/@/router";
import moitorHeader from "/@/components/monitor/header.vue";
import moitorSlider from "/@/components/monitor/slider.vue";
import rwSelect from "/@/components/RW/orgSelect.vue";
import { getList, getWarning } from "./index.api";
import { com } from "/@/utils/rw/common";
let timer = null;
const windowInstance: any = window;
const queryParams = ref({
  wardId: "",
});
//低电量告警数量
const selectArea = ref({
  types: "",
});
const deviceList = ref([]);
const warning = ref([]);
// 全部告警列表数据
getWarningList();
onMounted(() => {});

onUnmounted(() => {
  clearInterval(timer);
});
function getWarningList() {
  getWarning({}).then((res) => {
    console.log(res, "res");
    warning.value = res.data;
  });
}
function loadList(list) {
  queryParams.value.wardId = list[0].id;
  timer = setInterval(() => {
    obtainalarm();
  }, windowInstance.config.screen_time || 2000);
  obtainalarm();
}
function changeWard(id) {
  queryParams.value.wardId = id;
  obtainalarm();
}

function isAlarm(item, type) {
  return item.warns.some((l) => type.includes(l.warnType));
}
function hasSosAndLower(item) {
  return item.warns.filter((item) => {
    return item.warnType == "SOS" || item.warnType == "DeviceLowPower";
  });
}

function jump_millimeter() {
  router.push("/smartMattress");
}
function allRegions() {}
//实时告警
function obtainalarm() {
  getList(queryParams.value).then((res) => {
    deviceList.value = res.data;
  });
}
</script>
<style lang="scss">
.code {
  transition: all 0.3s ease;
}
.warning {
  .code {
    color: red !important;
  }
}
.hide {
  width: 500px !important;
  overflow: auto;
  height: 30vh;
  background-color: #0f285a;
  border: 1px solid #1b60cc;

  .el-table {
    background-color: rgba(255, 255, 255, 0);
  }
  .el-table .el-table__header-wrapper th {
    border-bottom: 1px solid #618ee2;
    background-color: rgba(255, 255, 255, 0);
    color: #fff;
  }
  .el-table__empty-text {
    color: #fff;
  }
  .el-table tr {
    background-color: rgba(255, 255, 255, 0);

    color: #fff;
  }
  .el-table--enable-row-hover .el-table__body tr:hover > td.el-table__cell {
    background-color: #618ee2;
    border-bottom: 1px solid #618ee2;
  }
  .el-table td.el-table__cell {
    border-bottom: 1px solid #4e88df;
  }
  .el-table::before {
    background-color: rgba(255, 255, 255, 0);
  }
}
.mattressHidden {
  width: 500px !important;
  height: 30vh !important;
  overflow: auto !important;
  position: absolute !important;
  top: 754px !important;
  left: 330px !important;
  background-color: #0f285a;
  border: 1px solid #1b60cc;
  margin-top: -12%;
  margin-left: 50px !important;
  .el-table {
    background-color: rgba(255, 255, 255, 0);
  }
  .el-table .el-table__header-wrapper th {
    border-bottom: 1px solid #618ee2;
    background-color: rgba(255, 255, 255, 0);
    color: #fff;
  }
  .el-table__empty-text {
    color: #fff;
  }
  .el-table tr {
    background-color: rgba(255, 255, 255, 0);

    color: #fff;
  }
  .el-table--enable-row-hover .el-table__body tr:hover > td.el-table__cell {
    background-color: #618ee2;

    border-bottom: 1px solid #618ee2;
  }
  .el-table td.el-table__cell {
    border-bottom: 1px solid #4e88df;
  }
  .el-table::before {
    background-color: rgba(255, 255, 255, 0);
  }
}

.big {
  .ant-select-selection-item,
  .ant-empty-description {
    color: #01c3e8 !important;
    font-size: 14px;
  }
  .select {
    width: 100% !important;
  }
  .ant-select {
    width: 100% !important;
  }
  .ant-select-selection-placeholder {
    color: #01c3e8 !important;
    font-size: 14px;
  }
  .ant-select-selector {
    border: none !important;
    background: transparent !important;
    font-size: 18px;
    color: #01c3e8;
    width: 100% !important;
  }
}

.button_right_a {
  font-size: 18px;
  text-align: center;
  color: #01c3e8;
  margin-top: 20px;
  .ant-select-item-option-selected {
    background-color: #01c3e8 !important;
    color: #fff !important;
  }

  .ant-select-selection-item {
    font-size: 14px !important;
    color: #01c3e8 !important;
  }
  .ant-select-dropdown {
    background: transparent;
    border: solid 1px #1b60cc !important;
  }
  .ant-select-dropdown__item.hover {
    background: transparent;
  }
}
.down_Box {
  font-size: 18px;
  text-align: center;
  color: #01c3e8;
  width: 100%;
  border: solid 1px #1b60cc !important;
  background: transparent;
  .ant-select-item-option-content {
    color: #fff !important;
  }
  .ant-select-item:hover {
    background-color: #1b60cc;
  }
  .ant-select-item-option-selected {
    background-color: #01c3e8 !important;
    color: #fff !important;
  }

  .ant-select-selector {
    border: none !important;
    background: transparent !important;
    font-size: 18px;
    color: #ffffff;
  }
  .ant-select-item-option-active:not(.ant-select-item-option-disabled) {
    background-color: transparent;
  }
  .el-input__suffix > .el-input__suffix-inner > .a-select__caret {
    color: #01c3e8;
    font-size: 18px;
  }
}

.list_text {
  font-size: 18px;
  text-align: center;

  width: 100% !important;
  .ant-select-item {
    background: transparent;
    background-color: #12264b !important;
    color: #ddd7d7 !important;
  }

  .ant-select-selector {
    border: none;
    background: transparent;
    font-size: 18px;
    color: #01c3e8 !important;
    border: none !important;
    width: 100%;
    background: transparent !important;
  }
  .ant-select-selection-item {
    color: #01c3e8 !important;
  }

  .ant-select-item:hover {
    background-color: #1b60cc;
  }
  .ant-select-dropdown {
    position: absolute;
    top: 50px !important;
    left: 0px !important;
    background-color: #12264b;
    border: solid 1px #1b60cc !important;
  }
}
.jeecg-default-layout-main {
  margin-left: 0;
}
.jeecg-setting-drawer-fearure {
  display: none;
}
</style>

<style lang="scss" scoped>
.warn {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  .SOS {
    background: url("../../../assets/ruijin/images/SOS.png") no-repeat;
  }
  .DeviceOffLine {
    background: url("../../../assets/ruijin/images/DeviceOffLine.png") no-repeat;
  }
  .warning {
    height: 100%;
    width: 100%;
    border-radius: 20px;
    background-size: 100% 100%;
    .text {
      color: #fff;
      text-align: center;
      font-size: 20px;
      line-height: 115px;
    }
  }
  ::v-deep .ant-carousel {
    height: 100%;
    width: 100%;
    .slick-slider,
    .slick-list,
    .slick-track,
    .slick-slide > div {
      height: 100%;
    }
  }
}
.no_device {
  text-align: center;
  font-size: 25px;
  color: #01c3e8;
  line-height: 100px;
}
.ant-select-item-option-content {
  color: #01c3e8 !important;
}
.app_containers {
  // min-width: 1700px;
  width: 100%;
  height: 100vh;
  background-image: url("../../../assets/ruijin/images/Underlay.png");
  background-size: 100% 100%;
  color: #fff;
  font-size: 12px;
  font-family: PingFangSC-Medium, PingFang SC, Microsoft YaHei;
  padding-bottom: 20px;
  display: block;
  .el-icon-back {
    font-size: 18px;
    text-align: center;
    font-family: TRENDS;
    margin-left: 20px;
  }
  .bgc {
    width: 100%;
    display: flex;
    .bgc_a {
      width: 230px;
      height: 30px;
      margin-left: 20px;
      margin-top: 30px;
      display: flex;
			cursor: pointer;
      background-color: #111(0, 0, 0, 0.1);
      border-radius: 25px 25px;
      box-shadow: 0px 0px 10px -2px rgb(247, 245, 245);
      .switchs {
        width: 28px;
        height: 20px;
        margin-left: 15px;
        background-repeat: no-repeat;
        display: inline-block;
        background-image: url("../../../assets/ruijin/images/jump.png");
        background-size: cover;
        margin-top: 5px;
      }
      .switch {
        line-height: 30px;
        font-size: 18px;
        font-family: TRENDS;
        margin-left: 15%;
      }
    }
  }

  .bgc_b {
    width: 190px;
    height: 30px;
    margin-left: 60px;
    margin-top: 30px;
    display: flex;
    background-color: #111(0, 0, 0, 0.1);
    border-radius: 25px 25px;
    box-shadow: 0px 0px 10px -2px rgb(247, 245, 245);
  }

  .m_main {
    padding: 0 !important;
    overflow: hidden;
    height: calc(100% - 90px);
    .box {
      width: 100%;
      height: 100%;
      display: flex;
      .contentSection {
        width: 80%;
        height: 100%;
        display: flex;
        flex-flow: wrap;
        overflow: auto;
        .box_a_bg {
          background-image: url("../../../assets/ruijin/images/border.png");
        }
        .box_a {
          width: 28%;
          height: 260px;
          margin-left: 5%;
          margin-top: 20px;
          max-width: 400px;
          margin-top: 20px;
          background-repeat: no-repeat;
          background-size: 100% 100%;
          position: relative;
          padding: 0 10px;
          .box_text_a {
            width: 100%;
            height: 30%;
            display: flex;
            white-space: nowrap;
            text-overflow: ellipsis;
            overflow: hidden;
            .box_text_b {
              color: #ffffff;
              font-size: 24px;
              margin-top: 30px;
              margin-left: 50px;
              margin-right: 50px;
            }
            .box_text_d {
              margin-top: 40px;
              margin-left: 20px;
            }
          }
          .box_text_c {
            width: 100%;
            height: 70%;
            display: flex;
            .box_text_g {
              width: 25%;
              height: 100%;
              position: relative;
              .box_text_l {
                font-size: 10px;
                line-height: 60px;
								text-align:center;
              }
              .iconfont {
                margin-left: 30px;
                font-size: 38px;
                color: #20c998;
              }
              .shang {
                position: absolute;
                top: 30%;
                font-size: 30px;
                margin-left: 65px;
              }
              .box_text_z {
                font-size: 10px;
                margin-left: 30px;
                line-height: 50px;
              }
              .box_text_k {
                font-size: 10px;
                margin-top: 10px;
                margin-left: 30px;
                line-height: 20px;
              }
              .box_text_Y {
                font-size: 10px;
                margin-left: 30px;
                line-height: 10px;
              }
            }
          }
        }
      }
      .right_module {
        width: 20%;
        height: 100%;
        margin-right: 10px;
        margin-left: 15px;
        margin-top: 10px;
        .right_top {
          width: 100%;
          height: 25%;
          display: flex;
          background-image: url("../../../assets/ruijin/images/border.png");
          background-repeat: no-repeat;
          background-size: 100% 100%;
          .right_top_a {
            width: 40%;
            .nurse {
              width: 55px;
              height: 60px;
              margin-top: 50%;
              margin-left: 40%;
              background-image: url("../../../assets/ruijin/images/nurse.png");
              background-repeat: no-repeat;
              background-size: 100% 100%;
            }
          }

          .nurse_Information {
            width: 60%;
            .InformationA {
              margin-top: 25%;
              font-size: 18px;
            }
            .InformationB {
              font-size: 18px;
              margin-bottom: 20px;
              margin-top: 20%;
            }
          }
        }
        .right_button {
          width: 100%;
          height: 73%;
          margin-top: 10px;
          background-image: url("../../../assets/ruijin/images/frame.png");
          background-repeat: no-repeat;
          background-size: 100% 100%;
          .alarm_list {
            width: 100%;
            height: 40px;
            padding-top: 20px;
            .list_text {
              font-size: 18px;
              text-align: center;
              line-height: 80px;
              color: #01c3e8;
            }
          }
          .list_data {
            width: 100%;
            height: 80%;
            .warning_content_ul {
              height: 100%;
              overflow: auto;
              padding: 0;
              .no_data {
                height: 100%;
                width: 100%;
                display: flex;
                justify-content: center;
                align-items: center;
                color: #ddd;
                font-size: 18px;
              }

              .a_a {
                width: 100%;
                height: 20%;
                margin-top: 2%;
                background-color: rgba(255, 255, 255, 0.1);

                .a_b {
                  display: flex;
                  font-size: 18px;
                  margin-left: 5%;
                  .a_t {
                    margin-top: 10px;
                    width: 55%;
                    height: 100%;
                    span {
                      margin: 10px;
                    }
                  }

                  .a_r {
                    position: relative;
                    left: 10%;
                    width: 30%;
                    height: 100%;
                    .bracelet_picture_a {
                      width: 20px;
                      height: 26px;
                      margin: 0;
                      margin-top: 10px;
                      margin-right: 20px;
                      display: inline-block;
                      background-image: url("../../../assets/ruijin/images/minibracelet.png");
                      background-repeat: no-repeat;
                      background-size: 100% 100%;
                    }
                    .a_g {
                      position: absolute;
                      top: 30%;
                    }
                  }
                }
                .a_c {
                  font-size: 15px;
                  padding-left: 5px;
                  margin-left: 20px;
                  margin-top: 10px;
                  display: flex;
                  .a_v {
                    margin-left: 10px;
                  }
                }
              }
            }
            .a_k {
              width: 100%;
              height: 100%;
              font-size: 18px;
              text-align: center;
            }
          }
        }
      }
    }
  }
}
</style>
